package com.dy.controller;

import com.dy.bean.SugarBean;
import com.dy.service.SugarServicer;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @projectName: day0603_2
 * @package: com.dy.controller
 * @className: SugarController
 * @author: DuanYu
 * @description: TODO
 * @date: 2024/6/3 21:15
 * @version: 1.0
 */
@RestController
public class SugarController {
    @Autowired
    SugarServicer sugarServicer;
    @RequestMapping("getMaxTwo")
    public Map showMaxTwo(){
        List<SugarBean> sugarDaos = sugarServicer.showMaxTwo();
        return SugarUtil.getPieData(sugarDaos);
    }
    @RequestMapping("getPp")
    public Map showPp(){
        List<SugarBean> sugarBeans = sugarServicer.showPp();
        return SugarUtil.getBarData(sugarBeans);
    }
    @RequestMapping("getMap")
    public Map showMap(){
        List<SugarBean> sugarBeans = sugarServicer.showMap();
        return SugarUtil.getMapData(sugarBeans);
    }
    @RequestMapping("getSum")
    public Map showSum(){
        Double aDouble = sugarServicer.showSum();
        Map map = new HashMap<>();
        map.put("status",0);
        map.put("data",aDouble);
        return map;
    }
    @RequestMapping("getSpu")
    public String showSpu() {
        List<SugarBean> sugarBeans = sugarServicer.showSpu();
        List list = new ArrayList<>();
        list.add("spu名称");
        list.add("金额");
        return SugarUtil.getTablePlayData(list,sugarBeans);
    }
}
